<?php

/**
 * This is the model class for table "{{bra_cat}}".
 *
 * The followings are the available columns in table '{{bra_cat}}':
 * @property integer $zbc_id
 * @property integer $zbc_parentid
 * @property integer $zbc_level
 * @property string $zbc_title
 * @property string $zbc_seotitle
 * @property string $zbc_seokey
 * @property string $zbc_seodesc
 * @property integer $zbc_listorder
 */
class BraCat extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return BraCat the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{bra_cat}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zbc_parentid, zbc_level', 'required'),
			array('zbc_parentid, zbc_level, zbc_listorder', 'numerical', 'integerOnly'=>true),
			array('zbc_title, zbc_seotitle', 'length', 'max'=>100),
			array('zbc_seokey, zbc_seodesc', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zbc_id, zbc_parentid, zbc_level, zbc_title, zbc_seotitle, zbc_seokey, zbc_seodesc, zbc_listorder', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zbc_id' => 'Zbc',
			'zbc_parentid' => 'Zbc Parentid',
			'zbc_level' => 'Zbc Level',
			'zbc_title' => 'Zbc Title',
			'zbc_seotitle' => 'Zbc Seotitle',
			'zbc_seokey' => 'Zbc Seokey',
			'zbc_seodesc' => 'Zbc Seodesc',
			'zbc_listorder' => 'Zbc Listorder',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zbc_id',$this->zbc_id);
		$criteria->compare('zbc_parentid',$this->zbc_parentid);
		$criteria->compare('zbc_level',$this->zbc_level);
		$criteria->compare('zbc_title',$this->zbc_title,true);
		$criteria->compare('zbc_seotitle',$this->zbc_seotitle,true);
		$criteria->compare('zbc_seokey',$this->zbc_seokey,true);
		$criteria->compare('zbc_seodesc',$this->zbc_seodesc,true);
		$criteria->compare('zbc_listorder',$this->zbc_listorder);

		$criteria->order = " zbc_listorder  ASC";//默认为时间倒序
		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}